const mysql = require('mysql');

//建立连接
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'demhem'
})
//执行连接
connection.connect();

//操作
connection.query('SELECT * FROM student',(error,result) => {
    if(error) {
        console.log('err ===>',error);
        console.log('错误')
    }
    if(result.affectedRows == 1){
        console.log('select 成功！！')
    }
    console.log('result',result);
})

//关闭数据库
connection.end();